package com.example.reggie.controller;

import com.example.reggie.common.R;
import com.example.reggie.entity.Orders;
import com.example.reggie.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@Slf4j
@RestController
@RequestMapping("/order")
public class OrdersController {
    @Autowired
     private OrderService orderService;
    @PostMapping("/submit")
    public R<String> orderSubmit(@RequestBody Orders order, HttpSession httpSession){
          order.setUserId((Long)httpSession.getAttribute("user"));
        orderService.sumbit(order);
        return R.success("下单成功");

    }




}
